package com.rt.cms.controller;

import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * Created by Administrator on 2018/7/2.
 */
@Controller
@RequestMapping("cmsSession")
public class SessionExpirationController {
    @ResponseBody
    @RequestMapping("/sessionExpiration")
    public Map<String,Object> sessionExpiration(HttpServletRequest request) {
        Map map = new HashedMap();

        String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort();


        String username = (String)SecurityUtils.getSubject().getPrincipal();
        if(StringUtils.isBlank(username)){
            map.put("status",0);
        }else{
            map.put("status",1);
        }
        map.put("cmsIndex",basePath);
        return map;
    }
}
